home *** CD-ROM | disk | FTP | other *** search
- #include <Quickdraw.h>
- #include "DebugDisplay.h"
- #define NIL 0
-
- extern char ShowDebugFlag; // are we showing our window
- extern long starvation; // how often we get execution cycles
- extern long deltastarv; // how much is it changing?
- extern long dissatisfaction;// how often we get to play notes
-
- static WindowPtr DebugWindow;
-
- void OpenDisplay(void)
- {
- int v,h;
- WindowPtr SavePort;
-
- if (ShowDebugFlag)
- {
- GetPort(&SavePort);
- /* 3. Load the window */
- DebugWindow = GetNewWindow(3,NIL, (WindowPtr)-1);
- SetPort(DebugWindow);
-
- /* 4. resize the window */
- HLock((Handle)DebugWindow);
- SizeWindow(DebugWindow,280,80,TRUE);
-
- /* 5. Position the window top third center */
- v = ((qd.screenBits.bounds.bottom - qd.screenBits.bounds.top)
- - (DebugWindow->portRect.bottom - DebugWindow->portRect.top)) / 7;
- h = ((qd.screenBits.bounds.right - qd.screenBits.bounds.left)
- - (DebugWindow->portRect.right - DebugWindow->portRect.left)) / 5;
- MoveWindow(DebugWindow,h,v,TRUE);
- HUnlock((Handle)DebugWindow);
-
- /* 6. Show the window */
- ShowWindow(DebugWindow);
- SetPort(SavePort);
- }
- }
-
- void DisposeDisplay(void)
- {
- if (ShowDebugFlag)
- if (DebugWindow!=NIL) {
- DisposeWindow(DebugWindow);
- DebugWindow = NIL;
- }
- }
-
- void UpdateDisplay(void)
- {
- WindowPtr SavePort;
- PicHandle Pic_Handle;
- Rect grayRect1,grayRect2,
- whiteRect1,whiteRect2,whiteRect3,
- deltastarvrect,starvRect,stormRect;
- SignedByte huhstate;
-
- if (ShowDebugFlag)
- if (DebugWindow!=NIL)
- {
- GetPort(&SavePort);
- SetPort(DebugWindow);
-
- // the deltastarv line
- if (deltastarv>0)
- SetRect(&deltastarvrect,25,24,(25+deltastarv),25);
- if (deltastarv<10) //if the delta is small, don't draw it.
- SetRect(&deltastarvrect,-10,-10,-10,-10);
- if (deltastarv<0)
- SetRect(&deltastarvrect,(25+deltastarv),24,25,25);
- // a white bar to overwrite the old one
- SetRect(&whiteRect3,0,24,350,25);
- // draw the damn thing
- FillRect(&whiteRect3,&qd.white);
- FillRect(&deltastarvrect,&qd.black);
-
- // the starv bar backgroundis gray,
- // then white to allow for "11"
- SetRect(&grayRect1,25,25,255,35);
- SetRect(&whiteRect1,255,25,350,35);
- // and here's the dk gray value bar
- SetRect(&starvRect,25,25,starvation+25,35);
- // and draw it
- FillRect(&grayRect1,&qd.ltGray);
- FillRect(&whiteRect1,&qd.white);
- FillRect(&starvRect,&qd.dkGray);
-
- // same story for the dissatisfaction bar
- SetRect(&grayRect2,25,50,255,60);
- SetRect(&whiteRect2,255,50,350,60);
- // here's the value part
- SetRect(&stormRect,25,50,dissatisfaction+25,60);
- // drawing
- FillRect(&grayRect2,&qd.ltGray);
- FillRect(&whiteRect2,&qd.white);
- FillRect(&stormRect,&qd.dkGray);
-
- SetPort(SavePort);
- }
- }